/**
 * axios 设置
 * Created by zhang.lu on 2017/9/26.
 */
import axios from 'axios'
import store from './store/index'
import { IS_SHOW_LOGIN_WINDOW } from './store/mutation-types'

// http响应拦截器
axios.interceptors.response.use(data => {
  console.log(data.request.responseURL)
  if (data.data && data.data.msgCode) {
    let response = {
      data: {
        data: [],
        success: false,
        message: data.data.description
      }
    }
    store.dispatch(IS_SHOW_LOGIN_WINDOW, true)
    return response
  }
  return data
}, error => {
  return Promise.reject(error)
})

export default axios
